const app = getApp();
const Controller = require('../controllers/controllers.js').controller;
const {formatTime} = require('../../utils/util.js');
Page({
  data: {
    myCompanydata:'',
    isloading:true,
    nodate:'',
    date:'',
    detail:'',
    number:''
  },
  onLoad: function (options) {
    this.countData()
    this.setData({
      nodate:formatTime(new Date())
    })
  },
  countData(){
    Controller.countData({type:1}).then(res=>{
      if(res.data.baseData){
        this.setData({
          myCompanydata:res.data.baseData
        })
      }
      this.setData({
        isloading:false
      })
    })
  },
  changeinput(e){
    this.setData({
      number:e.detail.value
    })
  },
  save(){
    if(!this.data.number){
      wx.showToast({
        title:"请输入预支工资",
        icon:"none"
      })
      return
    }
   
    var data={
      money:this.data.number
    }
    Controller.advancePay(data).then(res=>{
      wx.showToast({
        title:"提交成功",
        icon: 'success',
        duration: 2000
      })
      setTimeout(res => {
        wx.navigateBack({ //返回
          delta: 1
        })
      },2000)
    })
  },
  onShareAppMessage: function () {

  }
})